package com.zjj.exception.login;

import javax.security.auth.login.LoginException;

/**
 * @author zhoujunjie
 * @desc TODO
 * @date 2025/4/28
 */
// 登录服务类
// 登录服务类
class LoginService {
    private static final String CORRECT_USERNAME = "admin";
    private static final String CORRECT_PASSWORD = "password";

    public void login(String username, String password) throws LoginException {
        // 检查账户或密码是否为空
        if (username == null || username.isEmpty() || password == null || password.isEmpty()) {
            throw new LoginException("账户或密码不能为空");
        }
        // 检查账户与密码是否匹配
        if (!CORRECT_USERNAME.equals(username) || !CORRECT_PASSWORD.equals(password)) {
            throw new LoginException("账户与密码不匹配");
        }
        System.out.println("登录成功");
    }
}